package com.hmkj.web.controller;

import com.hmkj.common.entity.ResultEntity;
import com.hmkj.core.service.cache.MsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(description = "处理消息结果获取")
@RestController
@RequestMapping(value = GenericController.MEMBER_URL + "/msg")
public class MsgController extends GenericController {

    @Resource
    private MsgService msgService;

    @ApiOperation(value = "获得消息处理结果", notes = "获得消息处理结果<br/>type为固定类型")
    @RequestMapping(method = RequestMethod.POST)
    public ResultEntity msg(@ApiParam("tender:投资结果,transfer:投资转让项目结果") @RequestParam String type,
                            @ApiParam("请求返回数据") @RequestParam String key) {
        ResultEntity resultEntity = msgService.get(MsgService.MsgKey.findByType(type), key);
        return resultEntity == null ? loading() : resultEntity;
    }

}
